from types import MethodType


class MyClass:
    def __init__(self):
        self.name = "John"

    def printinfo(self):
        print(self.__class__.__name__)

def printinfo(self):
    print("Hello, world!")


obj = MyClass()
obj.printinfo()  # Output: MyClass


obj.printinfo = MethodType(printinfo, obj)
obj.printinfo()  # Output: MyClass

print(type(obj).__name__)
